package com.qiusuo0226.self.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qiusuo0226.self.mapper.BillRecordMapper;
import com.qiusuo0226.self.service.BillRecordService;
import com.qiusuo0226.self.pojo.entity.BillRecordDO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * 账单记录表 逻辑实现层
 * @author qiusuo
 * @date 2023/8/5 23:54
 */
@Slf4j
@Service
public class BillRecordServiceImpl extends ServiceImpl<BillRecordMapper, BillRecordDO> implements BillRecordService {

    @Override
    public boolean editRecordCategoryAll(String creater, String type, String oldCategory, String newCategory) {
        UpdateWrapper<BillRecordDO> updateWrapper = new UpdateWrapper<>();
        updateWrapper.set("bill_category", newCategory);
        updateWrapper.eq("creater", creater)
                .eq("bill_type", type)
                .eq("bill_category", oldCategory);
        int effectRows = baseMapper.update(null, updateWrapper);
        log.debug("根据创建者唯一标识和老账单类别修改所有账单记录的类别影响条数：{}", effectRows);
        return true;
    }
}
